<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="<%=path%>/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path%>/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="<%=path%>/js/jquery.min.js"></script>
    <script type="text/javascript">

        function deletes(id) {
            window.location.href = "<%=basePath%>deleteMember?memberId=" + id;
        }

        function modify(id) {
            window.location.href = "<%=basePath%>getMemberId?memberId=" + id;
        }

        function cz(id) {
            window.location.href = "<%=basePath%>getMemberId1?memberId=" + id;
        }

        $(function () {
            $('tbody tr:odd').addClass("trLight");

            $(".select-all").click(function () {
                if ($(this).attr("checked")) {
                    $(".checkBox input[type=checkbox]").each(function () {
                        $(this).attr("checked", true);
                    });
                } else {
                    $(".checkBox input[type=checkbox]").each(function () {
                        $(this).attr("checked", false);
                    });
                }
            });

        });
        function chgPageSize(size){
            document.forms[0].action="<%=basePath%>selectMember?pageNo=1&pageSize=" + size;
            document.forms[0].submit();
            return false;
        }
        function goPage(pageNo){
            if(pageNo<1){
                return false;
            }
            if(pageNo>${members.pageCount}){
                return false;
            }
            document.forms[0].action="<%=basePath%>selectMember?pageSize=${members.pageSize}&pageNo="+pageNo;
            document.forms[0].submit();
            return false;
        }
    </script>
    <style type="text/css">
        body {
            background: #FFF
        }
    </style>
</head>

<body>
<div id="contentWrap">
    <!--表格控件 -->
    <div id="widget table-widget">
        <div class="pageTitle">会员管理</div>
        <div class="querybody">
            <form action="<%=basePath%>selectMember">
                <ul class="seachform">
                    <li><label>会员ID</label><input name="memberId" type="text" class="scinput"/></li>
                    <li><label>会员名称</label><input name="realName" type="text" class="scinput"/></li>
                    <li><label>身份证</label><input name="credit" type="text" class="scinput"/></li>
                    <li><label>电话</label><input name="tel" type="text" class="scinput"/></li>
                    <li><label>&nbsp;</label><input name="" type="submit" class="scbtn" value="查询"/></li>
                </ul>
            </form>

        </div>
        <div class="pageColumn">
            <div class="pageButton"><a href="<%=path%>/html/memberadd.jsp"><img src="<%=path%>/images/t01.png"
                                                                                title="新增"/></a><span>会员列表</span></div>
            <table>
                <thead>
                <th width="">会员ID</th>
                <th width="">会员名称</th>
                <th width="">身份证</th>
                <th width="">电话</th>
                <th width="">卡余额</th>
                <th width="">年龄</th>
                <th width="">性别</th>
                <th width="">过敏史</th>
                <th width="">添加日期</th>
                <th width="10%">操作</th>
                <th width="10%">会员充值</th>
                </thead>
                <tbody>
                <c:forEach items="${members.list}" var="member">
                    <tr>
                        <td>${member.memberId}</td>
                        <td>${member.realName}</td>
                        <td>${member.credit}</td>
                        <td>${member.tel}</td>
                        <td>${member.balance}</td>
                        <td>${member.age}</td>
                        <td>${member.sex}</td>
                        <td>${member.anaphylaxis}</td>
                        <td><fmt:formatDate value="${member.createDate}" pattern="yyyy-MM-dd"/></td>
                        <td>
                            <a onclick="modify(${member.memberId})"><img src="<%=path%>/images/icon/edit.png" width="16"
                                                                         height="16"/></a>
                            <a onclick="deletes(${member.memberId})"><img src="<%=path%>/images/icon/del.png" width="16"
                                                                          height="16"/></a>
                        </td>
                        <td>
                            <a onclick="cz(${member.memberId})"><img src="<%=path%>/images/icon/edit2.png" width="16"
                                                                     height="16"/></a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div><!-- #widget -->
    <div id="pagination" style="align:right;margin-top:-10px;">
        <div id='project_pagination' class="pagination pagination-centered">
            <div class="pagination">
                <ul>
                    <li ><a href="javascript:goPage(${members.pageNo-1})">«</a></li>
                    <c:forEach begin="${members.pageNo-2<1?1:members.pageNo-2}" end="${members.pageNo+2}" var="cnt">
                        <c:if test="${cnt>=1 and cnt<=members.pageCount}">
                            <li class="${cnt==members.pageNo?'active':''}"><a href="javascript:goPage(${cnt})">${cnt}</a></li>
                        </c:if>
                    </c:forEach>


                    <li><a href="javascript:goPage(${members.pageNo+1})">»</a></li>
                </ul>
                <ul>
                    <li><span>(${members.firstResult+1}-${members.firstResult+members.pageSize>members.rowCount?members.rowCount:members.firstResult+members.pageSize}/${members.rowCount})</span></li>
                    <li><span>显示条数&nbsp;:&nbsp;</span></li>
                </ul>
                <ul>
                    <li class="${members.pageSize==2?'active':''}"><a href="javascript:chgPageSize(2)">2</a></li>
                    <li class="${members.pageSize==30?'active':''}"><a href="javascript:chgPageSize(30)">30</a></li>
                    <li class="${members.pageSize==50?'active':''}"><a href="javascript:chgPageSize(50)">50</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>
</body>
</html>
